package com.muxue.system.model;

import com.muxue.common.utils.spring.StringFormatter;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 缓存信息
 *
 * @author muxue
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class SysCache {

    /** 缓存名称 */
    private String cacheName = "";

    /** 缓存键名 */
    private String cacheKey = "";

    /** 缓存内容 */
    private String cacheValue = "";

    /** 备注 */
    private String remark = "";

    /**
     * 构造方法：仅初始化缓存名称和备注
     *
     * @param cacheName 缓存名称
     * @param remark    备注
     */
    public SysCache(String cacheName, String remark) {
        this.cacheName = cacheName;
        this.remark = remark;
    }

    /**
     * 构造方法：初始化缓存名称、键名和内容
     *
     * @param cacheName  缓存名称
     * @param cacheKey   缓存键名
     * @param cacheValue 缓存内容
     */
    public SysCache(String cacheName, String cacheKey, String cacheValue) {
        this.cacheName = StringFormatter.replace(cacheName, ":", "");
        this.cacheKey = StringFormatter.replace(cacheKey, cacheName, "");
        this.cacheValue = cacheValue;
    }
}